package stock;

import java.util.List;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class TestJGCGBL {

	public static void main(String[] args) {
		String url = "https://emweb.securities.eastmoney.com/pc_hsf10/pages/index.html?type=web&code=SZ002373&color=b#/gdyj/jgcc";

		WebDriver driver = StockServiceImpl.getdriver();
		;

		StockServiceImpl.driver.get(url);

		try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// driver.manage().timeouts().implicitlyWait(10000, TimeUnit.SECONDS);
		// 抓取网页内容
		// String pageContent = driver.getPageSource();

		WebElement element = driver.findElement(By.xpath("//div[@class='jgmx_content']//tr[@class='pointer active']")); 
		List<WebElement> elements = element.findElements(By.xpath("./following-sibling::tr"));

		for (int i = 0; i < elements.size(); i++) {
			if (i == elements.size() - 1) {
				List<WebElement> elements1 = elements.get(i).findElements(By.tagName("td"));
				for (int j = 0; j < elements1.size(); j++) {
					//System.out.println(elements1.get(j).getText());
					String tdtxt = elements1.get(j).getText();
					if (j == 1 || j == 4) {
						System.out.println(tdtxt);
					}
				}

			}
		}

	}
}
